<template>
  <el-select
    clearable
    filterable
    placeholder="请选择街道"
    class="ele-fluid"
    :value="value"
    @change="change">
    <el-option v-for="item in option" :key="item.id" :label="item.name" :value="item.id"/>
  </el-select>
</template>

<script>
export default {
  props: {
    value: Number,
  },
  model: {
    prop: 'value',
    event: 'change',
  },
  data: function () {
    return {
      option: [],
      loading: false,
    };
  },
  mounted() {
    this.loading = true
    this.$http.post('/street/index?page=1&limit=999').then(res => {
      if (res.data.code === 0) {
        this.option = res.data.data
      } else {
        this.$message.error(res.data.msg);
      }
      this.loading = false
    }).catch(e => {
      this.loading = false
      this.$message.error(e.message);
    });
  },
  methods: {
    change(val) {
      this.$emit('change', val);
    }
  },
};
</script>
